package d集合.day1.list;

import java.util.*;
import java.util.function.Consumer;

public class Demo1 {
    public static void main(String[] args) {
//        List c=new ArrayList();
        List c=new Vector();
        c.add("one");
        c.add("two");
        for (int i = 0; i < 10; i++) {
            c.add("for_"+i);
        }
        System.out.println(c.size());
//        c.add(c.size(),"first");

        System.out.println(c.contains("two"));
        System.out.println(c.get(0));
        System.out.println(c.indexOf("two"));
        Object[]arr=c.toArray();
        for (Object o : arr) {
            System.out.println(o);
        }
        System.out.println("===============遍历一==================");
        for (int i = 0; i < c.size(); i++) {
            System.out.println(c.get(i));
        }
        System.out.println("===========遍历二==============");
        for (Object o : c) {
            System.out.println(o);
        }
        System.out.println("=============遍历三==============");
        Consumer con=new Consumer() {
            public void accept(Object o) {
                System.out.println(o);
            }
        };
        c.forEach(con);
        System.out.println("===============遍历四=================");
        Iterator it=c.iterator();//产生一个指定，指向集合头之上
        while (it.hasNext()){//问一下，下面还是否有元素，有就返回true
            System.out.println(it.next());//取出当前位置之下的元素，并向下移动一个位置
        }
        System.out.println("=================================");
        System.out.println(c.toString());
    }
}
